<template>
    <div class="coord">
        <div class="operate">
            <el-button type="info" onclick="javascript:history.go(-1)">返回</el-button>

            <el-button type="primary" @click="makeMark">点击获取</el-button>
        </div>
        <Map :coordinate="coor" :flag="flag"></Map>
    </div>
</template>
<script>
import { defineComponent } from '@vue/composition-api'
import { getCurrentInstance} from 'vue'
import { useRouter,useRoute } from 'vue-router'
import { useStore } from 'vuex'
import Map from './map'
export default defineComponent({
    components:{
        Map
    },
    data(){
        return{
            coor:null,
            flag:''
        }
    },
    setup() {
        // 路由
        const router = useRouter();
        const route = useRoute();
        // vuex的数据对象
        const store = useStore();
        const { proxy } = getCurrentInstance();
        return{
            proxy,
            route,
            router,
            store
        } 
    },
    created () {
        this.loadData();
    },
    mounted () {
        this.flag = this.route.query.flag;
    },
    methods:{
        loadData(){
            let self = this;
            if(self.flag == 'base'){
                self.$http.get(`${self.baseUrl}/base/selectAll`).then(res=>{
                    self.coor = res.data.document;
                })
            }else if(self.flag == "pet"){
                let row = {};
                row.name = '';
                row.current = 1;
                row.end = 20;
                self.$http.post(`${self.baseUrl}/pet/UserByPet`,row).then(res=>{
                    self.coor = res.data;
                })
            }
        },
        makeMark(){
            this.loadData();
        }
    }
})
</script>
<style scoped>
    .My_history{
        color: #666;
        display: inline-block;
        cursor: pointer;
        margin: 0 40px 0 10px;
    }
    .coord{
        height: 646px;
        position: relative;
    }
    .operate{
        position: absolute;
        top: 20px;
        left: 30px;
        z-index: 10;
    }
</style>